package com.tuo51.evaluate.vo.evaluate;

import com.tuo51.evaluate.domain.evaluatingV2.EvaluateV2Question;
import com.tuo51.foudation.utils.CopyUtils;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 标签
 */
@Data
public class EvaluateV2QuestionVO {

    private String id;//用户id

    private Boolean deleted;

    private Date created;

    private Integer month = 0;

    private Integer indexOnPaper;

    private Integer optionGroup;

    private String optionTitle;

    private Integer shortIndex;

    private Boolean asPossibleAs;

    private String asPossibleAsTips;

    private String title;

    private String detail;

    private String guideVideo;

    private String guideVideoCover;

    private String operationGuide;

    private String passingCriteria;

    private Boolean parentAnswer;

    private List<EvaluateV2ToolVO> tools;

    private Boolean checked = null;

    private List options;

    public static EvaluateV2QuestionVO of(EvaluateV2Question template){
        template.getTools();
        EvaluateV2QuestionVO ret = new EvaluateV2QuestionVO();
        CopyUtils.copyProperties(template, ret);
        if (template.getTools() != null) {
            ret.setTools(template.getTools().stream().map(k-> EvaluateV2ToolVO.of(k)).collect(Collectors.toList()));
        }
        return ret;
    }

    public static EvaluateV2QuestionVO ofWithoutTools(EvaluateV2Question template){
        EvaluateV2QuestionVO ret = new EvaluateV2QuestionVO();

        BeanUtils.copyProperties(template, ret, "tools");

        return ret;
    }

}
